package com.qing.tcp;

import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class TcpSocketClient {
    public static void main(String[] args) {
        try {
            InetAddress ip = InetAddress.getByName("127.0.0.1");
            int port = 9999;
            //根据ip和端口创建一个socket连接
            Socket socket = new Socket(ip,port);
            //发送消息
            OutputStream os = socket.getOutputStream();
            os.write("好难呀！".getBytes());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
